clear all;
clc;
close all;

rng('shuffle')

N=1e5;

%%%%%%%%%%%%%%%%uniform
% a=10;b=22;
% ksi = (b-a)*rand(1,N)+a;
% bins = (a-2):0.1:(b+2);


%%%%%%%%%%%%%%%%gauss
% std=2;m=16;
% ksi  = std*randn(1,N)+m;

%%%%%%%%%%%%%%%%chi2
% std=2;m=5;
% x1 = std*randn(1,N)+m;
% x2 = std*randn(1,N)+m;
% ksi = x1.^2 + x2.^2;

% %%%%%%%%%%%%%%%%relay
% std=2;m=0;
% x1 = std*randn(1,N)+m;
% x2 = std*randn(1,N)+m;
% ksi = sqrt(x1.^2 + x2.^2);
% 
% %%%%%%%%%%%%%%%%Райс
% std=2;m=10;
% x1 = std*randn(1,N)+m;
% x2 = std*randn(1,N)+m;
% ksi = sqrt(x1.^2 + x2.^2);

m = [3,4,5];
d1 = 16;
d2 = 15.9;%xy yz
d3 = 15.9;%xz

L =chol([d1,d2,d3;
         d2,d1,d2;
         d3,d2,d1]);
     
ksi = nan(3,N);

for i = 1:N
    ksi(:,i) = L*randn(3,1);
end

[n,c] = hist3([ksi(1,:);ksi(2,:)]',[30,30]);

% [yh,xh] = hist(ksi,100);

% figure;
% hist(ksi,100)
% hold on;
% plot(xh,yh,'g','LineWidth',3)
% % ylim([0 1.2*max(yh)])
% hold off;
% 
% 
% 
% dxh = xh(2)-xh(1);
% ph = yh/(sum(yh)*dxh);
% 
% figure;
% plot(xh,ph)

surf(n);
